/**
 * file
 */
package com.tdkj.action.front.member.spaceManagement;

import java.util.List;

import javax.annotation.Resource;

import org.apache.struts2.ServletActionContext;

import com.opensymphony.xwork2.ActionContext;
import com.tdkj.action.BaseAction;
import com.tdkj.model.enterprisezone.BeanEnterprise;
import com.tdkj.model.enterprisezone.BeanEnterpriseNews;
import com.tdkj.model.enterprisezone.BeanEnterpriseProduct;
import com.tdkj.model.user.BeanUser;
import com.tdkj.service.enterprisezone.IBeanEnterpriseNewsService;
import com.tdkj.service.enterprisezone.IBeanEnterpriseProductService;
import com.tdkj.service.enterprisezone.IBeanEnterpriseService;
import com.tdkj.util.PublicConfing;

/**

 * FileName:     ProductManagement.java

 * @Description: TODO产品管理

 * All rights Reserved, Designed By ZTE-ITS

 * Copyright:    Copyright(C) 2010-2011

 * Company       天成科技有限公司

 * @author:    李兴建

 * @version    V1.0 

 * Createdate:         2012-5-27 上午11:50:01

 *

 * Modification  History:

 * Date         Author        Version        Discription

 * -----------------------------------------------------------------------------------

 * 2012-5-27       李兴建          1.0             1.0

 * Why & What is modified: <修改原因描述>

 */
public class ProductManagementAction extends BaseAction {
	private List<BeanEnterpriseProduct> productListWithoutExamine;
	private List<BeanEnterpriseProduct> productListWithExamined;
	private List<BeanEnterpriseProduct> productList;
	private IBeanEnterpriseProductService enterpriseProductService;
	private IBeanEnterpriseService enterpriseService;
	
	public String execute(){
		BeanUser user =  (BeanUser) ActionContext.getContext().getSession().get(PublicConfing.MEMBER_MEMBWE_OBJ_STRING_CONFIG);
		BeanEnterprise enterprise = user.getEnterprise();
		productList = enterpriseProductService.findByProperty("enterprise", enterprise ,BeanEnterpriseProduct.class);
		productListWithoutExamine = enterpriseProductService.findByProperty("examineState", "未审核", BeanEnterpriseProduct.class);
		productListWithExamined = enterpriseProductService.findByProperty("examineState", "审核通过", BeanEnterpriseProduct.class);
		return "success";
	}
	
	public String update(){
		return execute();
	}
	
	public String delete(){
		Long productId = Long.valueOf( ServletActionContext.getRequest().getParameter("productid"));
		BeanEnterpriseProduct product = enterpriseProductService.findById(productId, BeanEnterpriseProduct.class);
		enterpriseProductService.delete(product);
		return execute();
	}

	public List<BeanEnterpriseProduct> getProductListWithoutExamine() {
		return productListWithoutExamine;
	}

	public void setProductListWithoutExamine(
			List<BeanEnterpriseProduct> productListWithoutExamine) {
		this.productListWithoutExamine = productListWithoutExamine;
	}

	public List<BeanEnterpriseProduct> getProductListWithExamined() {
		return productListWithExamined;
	}

	public void setProductListWithExamined(
			List<BeanEnterpriseProduct> productListWithExamined) {
		this.productListWithExamined = productListWithExamined;
	}

	public List<BeanEnterpriseProduct> getProductList() {
		return productList;
	}

	public void setProductList(List<BeanEnterpriseProduct> productList) {
		this.productList = productList;
	}

	@Resource
	public void setEnterpriseProductService(
			IBeanEnterpriseProductService enterpriseProductService) {
		this.enterpriseProductService = enterpriseProductService;
	}
	@Resource
	public void setEnterpriseService(IBeanEnterpriseService enterpriseService) {
		this.enterpriseService = enterpriseService;
	}

}
